//
//  UserCacheManager.m
//  EaseIMTest
//
//  Created by yshow on 16/8/29.
//  Copyright © 2016年 yshow. All rights reserved.
//

#import "UserCacheManager.h"
#define UserName @"username"
#define UserImg  @"userImageUrl"
#define UserIDKey @"EaseUserInfo"

@implementation UserCacheManager

+(void)addUserInfo:(NSString *)userName userImg:(NSString *)userImg userId:(NSString *)userId
{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:userName forKey:UserName];
    [dict setValue:userImg forKey:UserImg];
    [[NSUserDefaults standardUserDefaults] setObject:dict forKey:[NSString stringWithFormat:@"%@%@",UserIDKey,userId]];
    [[NSUserDefaults standardUserDefaults] synchronize];
}


+(void)getUserInfoForKey:(NSString *)userId  block:(void (^)(NSString *userName, NSString * userImgUrl))block
{
    NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"%@%@",UserIDKey,userId]];
    
    block(dict[UserName],dict[UserImg]);
}

@end
